<script type="text/javascript" src="${base}/scripts/tool/pinyin.js"></script>
<script type="text/javascript ">
    //编码自动生成
    $("[name='sjzdsy.mc']").blur(function () {
        $("[name='sjzdsy.bm']").val($(this).val().toPY());
    })
    // **********加载数据字典值版块************
    $(function(){
        var url="${base}/base/sjzdz/sjzdz_List";
        if('${(sjzdsy.id)!''}')
            url+="?sjzdsyId=${(sjzdsy.id)!''}";
        $('#sjzdz_grid').edatagrid({
            url:url
        });

    });

    //新增按钮触发
    $('#sjzdz_add').click(
            addSjzdz
    );
    //取消按钮触发
    $('#sjzdz_cancel').click(
            cancelSjzdz
    );
    //删除按钮触发
    $('#sjzdz_del').click(
            destroySjzdz
    );
    //添加
    function addSjzdz() {
        $('#sjzdz_grid').edatagrid('addRow');
    }
    //取消
    function cancelSjzdz() {
        $('#sjzdz_grid').edatagrid('cancelRow');
    }
    //删除
    function destroySjzdz() {
        var row = $('#sjzdz_grid').datagrid('getSelected');
        var sjzdzId = row.id;
        var index = $('#sjzdz_grid').datagrid('getRowIndex',row);
        if(sjzdzId){
            $('#sjzdz_grid').datagrid('acceptChanges');
            var url =$.webPath()+"/base/sjzdz/delete_sjzdz?sjzdzId=" + sjzdzId;
            SjzdzSubmit(url,index);
        } else {
            $('#sjzdz_grid').edatagrid('destroyRow');
        }
    }
    //删除时直接删除数据库数据
    function   SjzdzSubmit(url,index){
        $.messager.confirm('确认', "是否确定删除?", function (r) {
            if (r) {
                $.ajax({
                    url: url,
                    type:"json",
                    success:function (data) {
                        if (data.statusCode == 200) {
                            $('#sjzdz_grid').datagrid('deleteRow',index);
                        } else {
                            $.messager.alert('提示', data.message, 'info');
                        }
                    }
                });
            }
        });
    }
</script>
<form id="form_sjzdsy" method="post" fit="true"
      action="${base}/base/sjzdsy/sjzdsy" method="post">
    <input type="hidden" name="sjzdsy.id" value="${(sjzdsy.id)!''}"/>
    <div class="easyui-tabs">
        <div title="数据字典索引">
            <table style="width:100%" class="tb tab-t">
                <col width="18%"/>
                <col width="32%"/>
                <col width="18%"/>
                <col width="32%"/>
                <tr style="height: 10px;"></tr>
                <tr>
                    <th style="color:#f45212;">名称：</th>
                    <td><input name="sjzdsy.mc" type="text" class="easyui-validatebox input-text" required="true"
                               validType="remote['${base}/base/sjzdsy/ajax_validate?sjzdsyId=${(sjzdsy.id)!}',{'validateField':'mc'},'索引名称不能重复！']" value="${(sjzdsy.mc)!''}"/></td>
                    <th>类型：</th>
                    <td>
                        &nbsp;&nbsp;  <label>
                        <input name="sjzdsy.lx" type="radio" value="0" style="vertical-align: middle;"
                               checked />系统类型</label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <label>
                            <input name="sjzdsy.lx" type="radio" value="1" style="vertical-align: middle;"
                                   <#if (sjzdsy.lx)?? && sjzdsy.lx==1>checked</#if>/>合同文本</label>
                    </td>
                </tr>
                <tr>
                    <th style="color:#f45212;">编码：</th>
                    <td><input name="sjzdsy.bm" type="text" class="easyui-validatebox input-text" required="true"
                               validType="remote['${base}/base/sjzdsy/ajax_validate?sjzdsyId=${(sjzdsy.id)!}',{'validateField':'bm'},'索引编码不能重复！']"
                               value="${(sjzdsy.bm)!''}"/></td>
                </tr>
                <tr>
                    <th>备注：</th>
                    <td><textarea  name="sjzdsy.bz" type="text" class="textarea"
                                   style="width:532px;height: 120px" rows="2"
                               value="${(sjzdsy.bz)!''}"/></td>

                </tr>
            </table>
        </div>
        <div title="数据字典值">
            <div id="sjzdz_tool" style="height:auto">
                <ul class="niu">
                    <li><a href="javascript:void(0)" id="sjzdz_add" plain="true">增加</a></li>
                    <li><a href="javascript:void(0)" id="sjzdz_del" class="del" plain="true">删除</a></li>
                    <li><a href="javascript:void(0)" id="sjzdz_cancel" class="rep" plain="true">取消</a></li>
                </ul>
            </div>
            <table style="width:100% " class="tb tab-t">
                <col width="10%"/><col width="35%"/><col width="10%"/><col width="35%"/>
                <tr>
                    <td>
                        <div>
                            <table id="sjzdz_grid" style="width:718px;height:auto"
                                   singleSelect="true">
                                <thead>
                                <tr>
                                    <th name="sjzdz.id" field="id" editor="numberbox" hidden="true">Id</th>
                                    <th name="sjzdz.z" field="z" width="100" editor="{type:'validatebox',options:{required:true}}">值</th>
                                    <th name="sjzdz.bz" field="bz" width="200" editor="text">备注</th>
                                    <th name="sjzdz.bm" field="bm" width="399" editor="text">编码</th>
                                </tr>
                                </thead>
                            </table>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>



